import { http } from "@/utils/http";
import type { FamilyInfoVO, UserResult } from "./types/user";
import type { RequestResponse } from "./types";

/** 登录 */
export const getLogin = (data?: object) => {
  return http.request<RequestResponse<UserResult>>(
    "post",
    "/api/v1/hdl/auth/passwordLogin",
    {
      data
    }
  );
};
/** 发送短信验证码 */
export const sendSmsCodeApi = (data?: object) => {
  return http.request<RequestResponse<UserResult>>(
    "post",
    "/api/v1/hdl/auth/sendSmsCode",
    {
      data
    }
  );
};
// 短信验证码登录
export const smsLogin = (data?: object) => {
  return http.request<RequestResponse<UserResult>>(
    "post",
    "/api/v1/hdl/auth/smsLogin",
    {
      data
    }
  );
};
// 获取用户信息
export const getLoginInfo = () => {
  return http.request<RequestResponse<any>>("get", "/api/v1/hdl/auth/getInfo");
};

// 获取家庭信息
export const getFamilyInfo = (params: { familyId: number }) => {
  return http.request<RequestResponse<FamilyInfoVO>>(
    "get",
    "/api/v1/hdl/app/family/info",
    { params }
  );
};

/** 验证重置密码验证码 */
export const verifyResetCodeApi = (data?: object) => {
  return http.request<RequestResponse<any>>(
    "post",
    "/api/v1/hdl/auth/verifyResetCode",
    {
      data
    }
  );
};

/** 重置密码 */
export const resetPasswordApi = (data?: object) => {
  return http.request<RequestResponse<any>>(
    "post",
    "/api/v1/hdl/auth/resetPassword",
    {
      data
    }
  );
};

/** 根据用户姓名查询用户高管和高管家属用户信息 */
export const getUserInfoByUserName = (data?: object) => {
  return http.request<RequestResponse<any>>(
    "post",
    "/api/v1/hdl/app/user/byUserName",
    {
      data
    }
  );
};

// /api/v1/hdl/app/doctor/updateInfo
export const updateDoctorInfo = (data: DoctorUpdateFrom) => {
  return http.request<RequestResponse<any>>(
    "post",
    "/api/v1/hdl/app/doctor/updateInfo",
    { data }
  );
};

// /api/v1/hdl/app/doctor/info
export const getDoctorInfo = () => {
  return http.request<RequestResponse<DoctorInfoVO>>(
    "get",
    "/api/v1/hdl/app/doctor/info"
  );
};

/**
 * DoctorUpdateFrom
 */
export interface DoctorUpdateFrom {
  /**
   * 用户姓名
   */
  actualName?: string;
  /**
   * 个人形象照片(资源Key)
   */
  appearanceKey?: string;
  /**
   * 医生头像(资源Key)
   */
  avatarKey?: string;
  /**
   * 医生用户ID
   */
  doctorUserId: number;
  /**
   * 性别
   * 1：男
   * 2：女
   */
  gender?: string;
  /**
   * 执业年限（医龄）
   */
  practiceYears?: number;
  /**
   * 个人简介
   */
  profile?: string;
  /**
   * 擅长项目
   */
  projects?: string;
  /**
   * 角色
   */
  role?: string;
  /**
   * 医生标签
   */
  tags?: string[];
}

/**
 * DoctorInfoVO
 */
export interface DoctorInfoVO {
  /**
   * 个人形象照片(资源Key)
   */
  appearance?: string;
  /**
   * 个人形象照片(资源Key)
   */
  appearanceKey?: string;
  /**
   * 医生头像
   */
  avatar?: string;
  /**
   * 医生头像(资源Key)
   */
  avatarKey?: string;
  /**
   * 医生用户姓名
   */
  doctorName?: string;
  /**
   * 医生用户ID
   */
  doctorUserId?: number;
  /**
   * 性别
   * 1：男
   * 2：女
   */
  gender?: string;
  /**
   * 医生手机号
   */
  phone?: string;
  /**
   * 执业年限（医龄）
   */
  practiceYears?: number;
  /**
   * 个人简介
   */
  profile?: string;
  /**
   * 擅长项目
   */
  projects?: string;
  /**
   * 角色
   */
  role?: string;
  /**
   * 医生标签
   */
  tags?: string[];
}
